// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import vuex from 'vuex'
import { ToastPlugin, LoadingPlugin } from 'vux'
import './filters/filter'
import BaiduMap from 'vue-baidu-map'
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import { DatetimePlugin } from 'vux'

var infiniteScroll = require('vue-infinite-scroll')

Vue.use(DatetimePlugin)
Vue.use(infiniteScroll)
Vue.use(vuex)
Vue.use(ToastPlugin, {
  position: 'top'
})
Vue.use(LoadingPlugin)
Vue.use(BaiduMap, {
  ak: 'aGf0sLjv7DOonc61fINdATGez2d3O8xB'
})
Vue.use(preview)

Vue.config.productionTip = false

Vue.prototype.playChatAudio = () => {
  const chatAudio = document.getElementById('chatAudio')
  chatAudio.currentTime = 0
  chatAudio.play()
}

Vue.prototype.playOrderAudio = () => {
  const orderAudio = document.getElementById('orderAudio')
  orderAudio.currentTime = 0
  orderAudio.play()
}

/* eslint-disable no-new */
if (process.env.NODE_ENV === 'development') {
  new Vue({
    el: '#app',
    store,
    router,
    components: { App },
    template: '<App/>'
  })
} else {
  document.addEventListener('deviceready', function () {
    new Vue({
      el: '#app',
      store,
      router,
      components: { App },
      template: '<App/>'
    })
    window.navigator.splashscreen.hide()
  }, false)
}

// document.addEventListener('deviceready', function () {
//   new Vue({
//     el: '#app',
//     store,
//     router,
//     components: { App },
//     template: '<App/>'
//   })
//   window.navigator.splashscreen.hide()
// }, false)
